#include "PSFPhotonDetHit.hh"

#include "G4UnitsTable.hh"

G4ThreadLocal G4Allocator<PSFPhotonDetHit> *PSFPhotonDetHitAllocator = nullptr;

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

PSFPhotonDetHit::PSFPhotonDetHit()
{
  fPosArrive = G4ThreeVector(0., 0., 0.);
  fPosExit = G4ThreeVector(0., 0., 0.);
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

PSFPhotonDetHit::PSFPhotonDetHit(G4ThreeVector pExit, G4ThreeVector pArrive,
                                 G4double pTime, G4double pEnergy, G4int pDetNumber, G4ThreeVector pDirection)
{
  fPosExit = pExit;
  fPosArrive = pArrive;
  fArrivalTime = pTime;
  fEnergy = pEnergy;
  fDetNumber = pDetNumber;
  fPosDirection = pDirection;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

PSFPhotonDetHit::PSFPhotonDetHit(const PSFPhotonDetHit &right)
    : G4VHit()
{
  *this = right;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

const PSFPhotonDetHit &PSFPhotonDetHit::operator=(const PSFPhotonDetHit &right)
{
  fPosExit = right.fPosExit;
  fPosArrive = right.fPosArrive;
  fArrivalTime = right.fArrivalTime;
  fEnergy = right.fEnergy;
  fDetNumber = right.fDetNumber;
  fPosDirection = right.fPosDirection;

  return *this;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

G4bool PSFPhotonDetHit::operator==(const PSFPhotonDetHit &right) const
{
  return fPosExit == right.fPosExit && fPosArrive == right.fPosArrive &&
         fArrivalTime == right.fArrivalTime && fEnergy == right.fEnergy && fDetNumber == right.fDetNumber && fPosDirection == right.fPosDirection;
}

void PSFPhotonDetHit::Print()
{

  G4cout
      << "Arrival time: "
      << std::setw(10) << std::fixed << std::setprecision(2) << G4BestUnit(fArrivalTime, "Time")
      << "Arrival position: ("
      << std::setw(10) << std::fixed << std::setprecision(2) << G4BestUnit(fPosArrive.x(), "Length") << ", "
      << std::setw(10) << std::fixed << std::setprecision(2) << G4BestUnit(fPosArrive.y(), "Length") << "); "
      << "Exit position: ("
      << std::setw(10) << std::fixed << std::setprecision(2) << G4BestUnit(fPosExit.x(), "Length") << ", "
      << std::setw(10) << std::fixed << std::setprecision(2) << G4BestUnit(fPosExit.y(), "Length") << "); "
      << "Energy: "
      << std::setw(10) << std::fixed << std::setprecision(2) << G4BestUnit(fEnergy, "Energy")
      << " Detector number: " << fDetNumber
      << G4endl;
}
